//
//  ArticleDetailTo.swift
//  weile
//
//  Created by LKM on 16/10/17.
//  Copyright © 2016年 LKM. All rights reserved.
//
import Foundation
import SwiftyJSON

//lkm
class ArticleDetailTo: NSObject {
    
    var Id: Int?;//115
    var AddTime: String?;//"2015-10-28T04:10:29"
    var Author: String?;//"管理员"
    var ClassId: Int?;//585
    var Click: Int?;//1
    var Content: String?;//"\r\n<p>\r\n\t政策新闻测试！</p>\r\n<p>\r\n\t政策新闻测试！</p>\r\n<p>\r\n\t政策新闻测试！</p>\r\n<p>\r\n\t政策新闻测试！</p>\r\n<p>\r\n\t政策新闻测试！</p>\r\n<p>\r\n\t政策新闻测试！</p>\r\n<p>\r\n\t政策新闻测试！</p>\r\n<p>\r\n\t政策新闻测试！</p>\r\n<p>\r\n\t政策新闻测试！</p>\r\n<p>\r\n\t&nbsp;</p>\r\n"
    var Channels: String?;//",582,"
    var Content_e: String?;//""
    var Daodu: String?;//""
    var Daodu_e: String?;//""
    var Form: String?;//"本站"
    var ImgUrl: String?;//"/UpLoadFiles/20160926/2016092611014336.jpg"
    var IsHot: Int?;//1
    var IsLock: Int?;//0
    var IsMsg: Int?;//0
    var IsRed: Int?;//0
    var IsSlide: Int?;//0
    var IsTop: Int?;//0
    var Keyword: String?;//""
    var Title: String?;//"政策新闻测试"
    var Title_e: String?;//""
    var Zhaiyao: String?;//""
    var Zhaiyao_e: String?;//""
    var iskeep: Int?;//"0"
    
    //dict["data"].dictionaryObject  dict是JSON
    init?(jsons: [String: JSON]?) {
        super.init()
        
        if(jsons == nil){
            return nil
        }
        if let dict = jsons{
            
            self.Id = dict["Id"]?.int;//115
            self.AddTime = dict["AddTime"]?.string;//"2015-10-28T04:10:29"
            self.Author = dict["Author"]?.string;//"管理员"
            self.ClassId = dict["ClassId"]?.int;//585
            self.Click = dict["Click"]?.int;//1
            self.Content = dict["Content"]?.string;//"\r\n<p>\r\n\t政策新闻测试！</p>\r\n<p>\r\n\t政策新闻测试！</p>\r\n<p>\r\n\t政策新闻测试！</p>\r\n<p>\r\n\t政策新闻测试！</p>\r\n<p>\r\n\t政策新闻测试！</p>\r\n<p>\r\n\t政策新闻测试！</p>\r\n<p>\r\n\t政策新闻测试！</p>\r\n<p>\r\n\t政策新闻测试！</p>\r\n<p>\r\n\t政策新闻测试！</p>\r\n<p>\r\n\t&nbsp;</p>\r\n"
            self.Channels = dict["Channels"]?.string;//",582,"
            self.Content_e = dict["Content_e"]?.string;//""
            self.Daodu = dict["Daodu"]?.string;//""
            self.Daodu_e = dict["Daodu_e"]?.string;//""
            self.Form = dict["Form"]?.string;//"本站"
            self.ImgUrl = dict["ImgUrl"]?.string;//"/UpLoadFiles/20160926/2016092611014336.jpg"
            self.IsHot = dict["IsHot"]?.int;//1
            self.IsLock = dict["IsLock"]?.int;//0
            self.IsMsg = dict["IsMsg"]?.int;//0
            self.IsRed = dict["IsRed"]?.int;//0
            self.IsSlide = dict["IsSlide"]?.int;//0
            self.IsTop = dict["IsTop"]?.int;//0
            self.Keyword = dict["Keyword"]?.string;//""
            self.Title = dict["Title"]?.string;//"政策新闻测试"
            self.Title_e = dict["Title_e"]?.string;//""
            self.Zhaiyao = dict["Zhaiyao"]?.string;//""
            self.Zhaiyao_e = dict["Zhaiyao_e"]?.string;//""
            self.iskeep = dict["iskeep"]?.int;//""
        }
    }
    
    
    //initToList( json:JSON(dict["huxing"] ) )  把JSON过的Any转为JSON
    //一定要是JSON要是 [Any] 的话 会装换失败，最后我还是选用这个JSON
    class func initToList(json: JSON)->[ArticleDetailTo?]{
        if let items = json.array {
            var results = [ArticleDetailTo?]()
            for item in items {
                let result = ArticleDetailTo(jsons: item.dictionary )
                //                if(result != nil){//空还加个屁啊  json为“[]” 时 这是不会为空的。除非直接来了个nil
                //                    results.append(result!)
                //                }
                results.append(result)
            }
            return results;
        }
        return [ArticleDetailTo?]()
    }
    
    //initToList( json:JSON(dict["huxing"] ) )  把JSON过的Any转为JSON
    //一定要是JSON要是 [Any] 的话 会装换失败，最后我还是选用这个JSON
    class func initToMap(json: JSON)->Dictionary<String,ArticleDetailTo>{
        if let items = json.dictionary {
            var results = Dictionary<String,ArticleDetailTo>()//取值的时候本身就是可选类型啊,所以这里不用跟数组一样弄可选类型
            for (key, value)  in items {
                let result = ArticleDetailTo(jsons: value.dictionary )
                results[key] = result
            }
            return results;
        }
        return Dictionary<String,ArticleDetailTo>()
    }
    
    

    
    
}

